package priv.yiyuan.example.composite.ticket;

/**
 * 工单抽象类
 * <p>
 * 组合模式-组件
 *
 * @author YiYuan
 * @data 2025/8/29
 * @apoNote
 */
public abstract class TicketComponent {

    protected String ticketId;

    protected String description;

    protected TicketComponent parent;

    protected TicketStatus status = TicketStatus.OPEN;

    public TicketComponent(String ticketId, String description) {
        this.ticketId = ticketId;
        this.description = description;
    }

    public void setParent(TicketComponent parent) {
        this.parent = parent;
    }

    public TicketComponent(TicketComponent parent) {
        this.parent = parent;
    }

    public abstract void add(TicketComponent component);

    public abstract void remove(TicketComponent component);

    public abstract void process(TicketHandler handler);

    public abstract boolean isCompleted();

    public abstract void display(String indent);

    public void updateStatus(TicketStatus status) {
        this.status = status;
        System.out.println("工单 " + ticketId + " 状态更新为: " + status);
    }
}
